﻿@using Microsoft.AspNetCore.Identity
@inject UserManager<IdentityUser> _userManager;
@model List<IdentityUser>
@{
    ViewData["Title"] = "Index";
}

<h2>用户管理</h2>
<a class="btn btn-info" asp-action="Register" asp-controller="account">添加用户</a>
<table class="table table-hover">
    <thead>
        <tr>
            <th>Id</th>
            <th>用户名</th>
            <th>Email</th>
            <th>Claim(授权授权声明)</th>
            <th>角色</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var user in Model)
        {
            <tr>
                <td>@user.Id</td>
                <td>@user.UserName</td>
                <td>@user.Email</td>
                <td>@string.Join(',', await _userManager.GetClaimsAsync(user))</td>
                <td>@string.Join(',', await _userManager.GetRolesAsync(user))</td>
                <td>
                    <a asp-controller="User" asp-action="Edit" asp-route-id="@user.Id">编辑</a>
                    
                    <a onclick="return confirm('确认删除吗？')" href="/user/delete/@user.Id" >删除</a>
                </td>
            </tr>    
        }
    </tbody>
</table>

